<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="styles/base.css?v=2">
  <title>熊猫部落-首页</title>
  <style>
    body {
      position: absolute;
      margin: 0;
      padding: 0;
      width: 1280px;
      height: 720px;
      background: url(images/index-bg.jpg);
      background-color: transparent;
    }
  </style>
</head>

<body onload="init()" onunload="exit()">
  <img id="logo" src="images/logo.png" alt="">
  <div id="nav">
    <!-- <div id="nav-0" class="nav-item"></div>
    <div id="nav-1" class="nav-item"></div>
    <div id="nav-2" class="nav-item"></div>
    <div id="nav-3" class="nav-item"></div> -->
  </div>
  <div id="search">
    <div id="search-0" class="search-item">
      <div class="bg bg-0"></div>搜索
    </div>
    <div id="search-1" class="search-item">
      <div class="bg bg-1"></div>收藏
    </div>
    <div id="search-2" class="search-item">
      <div class="bg bg-2"></div>记录
    </div>
  </div>
  <div id="main"></div>
  <div id="test"></div>
</body>


<script src="js/jquery.js"></script>
<script src="config/index.js?v=1"></script>
<script src="api/index.js?v=1"></script>
<script src="js/KeyEvent.js?v=12"></script>
<script src="js/event.js?v=12"></script>
<script src="js/utli.js?v=12"></script>
<script src="js/base.js"></script>
<script src="js/promise.min.js"></script>
<script src="js/mediaplayer.js"></script>

<script>
  // parent.location.href = 'http://172.48.2.1/panda/index.html'
  var area = initAear();
  var loading = false;
  var isNeed = 0;
  var lookTimer = null;
  var lookTime = 15;
  var isSub = -1; // 0 为鉴权通过，2鉴权错误。其他 鉴权不通过
  var first = false; // 第一次登录
  var visible = false; //是否显示弹出层
  var orderIndex = 1; // 弹出层焦点
  //  showTest(location.href)

  function renderNav() {
    var html = '';
    var data = getTypeListByTypeId({
      TYPEID: TYPEIDS.HOME
    }).TYPEs
    for (var i = 0, l = data.length; i < l; i++) {
      html += '<div id="nav-' + i + '" class="nav-item" style="background-image:url(' + data[i].typePicture[0]
        .picPath3 + ')"></div>'
      // $('#nav-' + i).css('background-image', 'url(' + data[i].typePicture[0].picPath3 + ')')
    }
    $('#nav').html(html);
  }

  function initAear() {
    return [{
        id: 'nav-',
        index: 0
      },
      {
        id: 'search-',
        index: 0
      },
      {
        id: 'main-0-',
        index: 0
      },
      {
        id: 'main-1-',
        index: 0
      },
      {
        id: 'main-2-',
        index: 0
      },
      {
        id: 'main-3-',
        index: 0
      },
      {
        id: 'main-4-',
        index: 0
      }
    ]
  }

  function getPreFocus() {
    var url = window.location.href;
    focusArea = parseInt(GY.getURLParameter("AREA", url) != "" ? GY.getURLParameter(
      "AREA", url) : 0);
    header = parseInt(GY.getURLParameter("HEADER", url) != "" ? GY.getURLParameter(
      "HEADER", url) : 0);
    index = parseInt(GY.getURLParameter("INDEX", url) != "" ? GY.getURLParameter(
      "INDEX", url) : 0);
    isOrder = parseInt(GY.getURLParameter("IS_ORDER", url) != "" ? GY.getURLParameter(
      "IS_ORDER", url) : 0);
    orderId = GY.getURLParameter("ORDER_ID", url) != "" ? GY.getURLParameter(
      "ORDER_ID", url) : '0';
    proId = GY.getURLParameter("PRO_ID", url) != "" ? GY.getURLParameter(
      "PRO_ID", url) : '';

  }

  // 订购后回调通知后台
  function postOrder() {
    var obj = {
      programId: '',
      programName: '',
      ctype: ''
    }
    if (isOrder == 0 && proId == '') return
    var productList = filmDate.productObject.productList;

    if (orderId == 0) {
      obj.programId = 0;
      obj.programName = '弹窗订购'
    } else {
      obj.programId = orderId;
      obj.programName = getVodDetailInfo({
        VODID: orderId
      }).name
    }

    for (var i = 0, l = productList.length; i < l; i++) {
      if (productList[i].productId == proId) {
        obj.ctype = productList[i].name;
        break;
      }
    }

    testOrder(obj)

  }
  function testOrder(obj){
    console.error(obj)
  }




  function init() {
    clearReturnPage();
    addDoMain(window.location.href);
    getFilmDate()
    getPreFocus();
    postOrder();
    renderNav();
    renderMain(header);
  }

  function renderMain(header) {
    var url = '';
    loading = true;
    area = initAear();
    checkMark(header);
    if (focusArea != 0) {
      area[focusArea].index = index;
    }
    switch (header) {
      case 0:
        url = 'main-1.html';
        break;
      case 1:
        url = 'main-2.html';
        break;
      case 2:
        url = 'main-3.html'
        break;
      case 3:
        url = 'main-4.html'
        break;
    }
    $.ajax({
      url: url,
      type: 'get',
      cache: true,
      success: function (data) {
        loading = false;
        $('#main').html(data);
      }
    })
  }

  function checkMark(header) {
    area[0].index = header;
    $('.nav-item').eq(header).addClass('active').siblings('.nav-item').removeClass('active');
  }

  function keyBack() {
    if (visible) {
      $('#dialog').css('display', 'none');
      visible = false;
    } else {
      GY.goback();
    }
  }

  function exit() {
    // var url =  "index.html?AREA=" + focusArea + "&INDEX=" + area[focusArea].index + '&HEADER=' +
    //   area[0].index;
    // GY.addUrl(url, isNeed);
    // clearDomainPath();
    destroy()
  }

  function onFocus() {
    var eFocus = $('#' + area[focusArea].id + area[focusArea].index);
    eFocus.addClass('focus');
    starMarquee(eFocus)
  }



  function freeFocus() {
    var eFocus = $('#' + area[focusArea].id + area[focusArea].index);
    eFocus.removeClass('focus');
    stopMarquee(eFocus)
  }
</script>

</html>